﻿using System;
using System.Threading.Tasks;

namespace Demo
{
    public interface IHttpApplication<TContext>
    {
        TContext CreateContext(IFeatureCollection contextFeatures);
        
        Task ProcessRequestAsync(TContext context);
        
        void DisposeContext(TContext context, Exception exception);
    }

    public class HostingApplication : IHttpApplication<RequestContext>
    {

        private readonly RequestDelegate _application;

        public HostingApplication(RequestDelegate application)
        {
            _application = application;
        }

        public RequestContext CreateContext(IFeatureCollection contextFeatures)
        {
            return null;
        }

        public Task ProcessRequestAsync(RequestContext context)
        {
            return _application(context);
        }

        public void DisposeContext(RequestContext context, Exception exception)
        {

        }
    }
}
